Home / C (page 4)

C

c program to print fibonacci numbers using recursion

Fibonacci numbers using recursion You must have already come across program to print fibonacci numbers without recursion, Here is given fbonacci number series using recursion. PROS or New concept used: 1. You DONT have to print 0 and 1 first and run the loop n-2 times. 2. Giving modularity to program since recursion uses function or method thus decreases complexity ...

Read More »

C program for binary to decimal conversion

Here is given c program for binary to decimal conversion. But before let us see what is a Binary number is? A binary number is a number formed using only two digits i.e 1 or 0. A Decimal number is a number with base 10 which is in used very efficiently for manually calculations.Let us understand the conversion process through ...

Read More »

c program to print first 20 fibonacci numbers

This is a c program to print fibonacci numbers where fibonacci numbers are those where every next number in the series is the sum of the previous two numbers and the series starts with the former numbers 0 and 1. So fibonacci series is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ….. so on.

Read More »

c program for pattern13

 C program for pattern making        1      21   321 4321 Here is given c program for following pattern. In the above pattern we have two triangle one is empty space triangle together with the shown triangle. That’s why we have to put the loop for empty spaces together with the loop for the shown triangle. ...

Read More »

c program to check for twin prime numbers

Here is given c program for Twin Prime numbers. But before let us see what exactly is a Twin Prime  number ? A Twin Prime number are those numbers which are prime and having a difference of 2 between the two prime numbers. Example: 11 and 13. These numbers are itself prime numbers with a difference of 2 between them ...

Read More »

C program for Kaprekar number

Here is given c program for Kaprekar number. But before what exactly is a Kaprekar number? A Kaprekar number is a number whose square can be broken/partitioned in such a manner that the sum of the partitions adds up to bring the number itself. Example: 992 = 9801 : 98+01 = 99  (hence kaprekar) // This program is however limited ...

Read More »

C program for Magic number

This is a C program for Magic number. A Magic number is a number whose sum of digits eventually leads to 1. Example#1:  19 ;  1+9 =10 ; 1+0 = 1.  Hence a magic number. Example#2:  224; 2+2+4=10; 1+0 =1.  Hence a magic number. Example#3:  874; 8+7+4=19; 1+9=10; 1+0=1.  Hence a magic number. Also Check: Java program to check for ...

Read More »

c program to print the desired shape empty or filled

First parameter should be a character to choose the shape that will be printed. It could be ‘T’ or ‘t’ for triangle, ‘R’ or ‘r’ for rectangle, ‘P’ or ‘p’ for parallelogram, ‘D’ or ‘d’ for diamond. Second parameter should be a number which identifies the height of the shape. The height should be minimum 2 for triangle, rectangle and ...

Read More »

C program to remove extra blank spaces from a file

Many a times is happens that when you copy content from a incompatible source then extra spaces are added which is due to mismatched format. To get rid of this here is program in c to remove extra blank spaces from a file.. In this content of a file are added to a new file named newfile.txt which contains content ...

Read More »

C program to remove extra lines or blank lines from a file

C program for removing line spacing from a file and copying it to another file or program to remove extra blank lines within a file. #include <stdio.h> #include <stdlib.h> int main() { FILE *fp,*fp2; int p; char *filename; printf("enter the file name from which you have to remove the blank lines: "); scanf("%s",filename); printf("%s",filename); fp=fopen(filename,"r"); fp2=fopen("newfile.txt","w"); //all the content gets ...

Read More »