• C language

    Take Input From User Of Different Datatypes In C

    Here, printf() is used to display text on the screen. The sign & is used to assign the input value to the variable and store it at that particular location. scanf() is used to take input from the user using format specifier. %d and %i, both are used to take integer numbers as input from the user. %f is the format specifier to take float as input from the user. %c is the format specifier to take character as input from the user. %s is the format specifier to take string as input from the user but %s cannot get string with white space from user,…

  • C language

    Fibonacci Series With Recursion And Without Recursion

    There are two ways to write the Fibonacci Series program: Fibonacci Series without recursion Fibonacci Series using recursion Fibonacci Series Without Recursion #include<stdio.h> #include<conio.h> void main() { int n1=0,n2=1,n3,i,number; clrscr(); printf("Enter the number of elements:"); scanf("%d",&number); printf("\n%d %d",n1,n2); //print 0 and 1 for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed { n3=n1+n2; printf(" %d",n3); n1=n2; n2=n3; } getch(); } OutPut Enter the number of elements:15 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 Fibonacci Series With Recursion #include<stdio.h> #include<conio.h> void printFibonacci(int n){ static int n1=0,n2=1,n3; if(n>0) { n3 =…

  • C language

    Printing Hello World In C

    Here, the C program prints “Hello World!” in the output window. And, all syntax and commands in C programming are case sensitive. Also, each statement should be ended with semicolon (;) which is a statement terminator. Here, stdio.h is header file that contains all standard libraries for input and output. #include<stdio.h> #include<conio.h> void main() { clrscr(); printf("Hello World!"); getch(); } OutPut : Hello World!