1. Simple C Program Hello World




  2. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { printf("hello world"); getch(); }

    Output
    hello world



  3. Get Two Numbers From User And Check Them Same Or Not Same




  4. Example
    #include<stdio.h>
    #include<conio.h>
    
    int main() { int m,n; printf("Enter first num :"); scanf("%d",&m); printf("Enter second num :"); scanf("%d",&n); if (m==n) { printf("Your numbers are same"); } else { printf("Your numbers are not same"); } }

    Output
    Enter first num :43
    Enter second num :43
    Your numbers are same



  5. Get To Num From User And Do 1]Add 2]Sub 3]Mult 4]Div




  6. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a,b,c; printf("Enter first num :"); scanf("%d",&a); printf("Enter second num :"); scanf("%d",&b); c=a+b; printf("\n The Add is=%d",c); c=a-b; printf("\n The Sub is=%d",c); c=a*b; printf("\n The Mult is=%d",c); c=a/b; printf("\n The Divi is=%d",c); getch(); }

    Output
    Enter first num :30
    Enter second num :45
    The Add is=75
    The Sub is=-15
    The Mult is=1350
    The Divi is=0



  7. Get 3 Subject Marks From User And Show Result




  8. Example
    #include<stdio.h>
    #include<conio.h>
    
    int main() { int a,b,c; float result; printf("Enter first subject marks:"); scanf("%d",&a); printf("Enter second subject marks:"); scanf("%d",&b); printf("Enter therd subject marks:"); scanf("%d",&c); result=(a+b+c)/3; printf("Your result is=%f",result); getch(); }

    Output
    Enter first subject marks:45
    Enter second subject marks:30
    Enter therd subject marks:26
    Your result is=33.000000



  9. Get Radius From User And Show Area Of Circle




  10. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { float r,area; printf("Enter the radius :"); scanf("%f",&r); area=3.14*r*r; printf("Area of circle is=%f",area); getch(); }

    Output
    Enter the radius :32
    Area of circle is=3215.360107



  11. Get Base And Height From User And Show Area Of Traingle




  12. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { float b,h,area; printf("Enter the base :"); scanf("%f",&b); printf("Enter the height :"); scanf("%f",&h); area=0.5*b*h; printf("Area of traingle is=%f",area); getch(); }

    Output
    Enter the base :45
    Enter the height :12
    Area of traingal is=270.000000



  13. Get Age from User And Show Them Can Make Pan Card Or NoT




  14. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int n; printf("Enter your age :"); scanf("%d",&n); if(n<=18) { printf("You can now make pan card, thank you"); } else { printf("Sorry you can't make pan card, thank you"); } getch(); }

    Output
    Enter your age :19
    Sorry you can't make pan card, thank you



  15. Get Number from User And Show Them Even Or Odd




  16. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a; printf("Enter the num :"); scanf("%d",&a); if (a%2==0) { printf("The num is even"); } else { printf("The num is odd"); } }

    Output
    Enter the num :45
    The num is odd



  17. Get Charector From User And Show Them Vowel Or Not




  18. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { char ch; printf("Enter the charector :"); scanf("%c",&ch); if(ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I'||ch=='o'||ch=='O'||ch=='u'||ch=='U') { printf("%c is vowel, thank you",ch); } else { printf("%c is not vowel, thank you",ch); } getch(); }

    Output
    Enter the charector :u
    u is vowel, thank you



  19. Get 3 Number From User And Show Them Which Is Greater




  20. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a,b,c; printf("Enter 1st number :"); scanf("%d",&a); printf("Enter 2nd number :"); scanf("%d",&b); printf("Enter 3rd number :"); scanf("%d",&c); if((a>b)&&(a>c)) { printf("%d is greater number, thank you",a); } if((b>a)&&(b>c)) { printf("%d is greater number, thank you",b); } if((c>b)&&(c>a)) { printf("%d is greater number, thank you",c); } getch(); }

    Output
    Enter 1st number :45
    Enter 2nd number :12
    Enter 3rd number :12
    45 is greater number, thank you



  21. Get Charector From User And Show Them Vowel Or Not By Using Switch




  22. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { char ch; printf("Enter the charector :"); scanf("%c",&ch); switch(ch) { case 'a': case 'A': case 'E': case 'e': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': printf("%c is vowel",ch); break; default: printf("%c is not vowel",ch); } getch(); }

    Output
    Enter the charector :u
    u is vowel



  23. Get Number From User And Show Them In Reverce Order




  24. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int n,num,sum=0; printf("Enter the numbers:"); scanf("%d",&n); while(n>0) { num=n%10; sum=sum*10+num; n=n/10; } printf("Reverce no. is=%d",sum); getch(); }

    Output
    Enter the numbers:186
    Reverce no. is=681



  25. Get Number From User And Fiend Factorial Of Them




  26. Example
    #include<stdio.h>
    #include<conio.h>
    
    int main() { int n,fact,num; printf("Enter the number : "); scanf("%d",&n); fact=1; num=n; while(n>0) { fact=fact*n; n--; } printf("Factorial of %d=%d",num,fact); getch(); return 0; }

    Output
    Enter the number : 5
    Factorial of 5=120



  27. Get Number From User And Fiend Odd Numbers Up To User Number And Show Addition Of Odd Numbers




  28. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a,b,c,sum=0; printf("Enter the num : "); scanf("%d",&a); for(b=1;b<=a;b++) { if(b%2!=0) { printf("\n%d",b); sum=sum+b; } } printf("\n\nThe addition of odd numbers is = %d",sum); getch(); }

    Output
    Enter the num : 18

    1
    3
    5
    7
    9
    11
    13
    15
    17

    The addition of odd numbers is = 81



  29. Get Number From User And Fiend Number Armstrong Or Not




  30. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a,sum=0,temp,rem; printf("Enter the number : "); scanf("%d",&a); temp=a; while(temp!=0) { rem=temp%10; sum=sum+rem*rem*rem; temp=temp/10; } if(a==sum) { printf("number is armstrong"); } else { printf("number is not armstrong"); } getch(); }

    Output
    Enter the number : 153
    number is armstrong



  31. Get Number From User And Show Them Table Of This Number




  32. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a,b=1,c; printf("Enter the number : "); scanf("%d",&a); while(b<=10) { c=a*b; printf("\n%d",c); b++; } getch(); }

    Output
    Enter the number : 8

    8
    16
    24
    32
    40
    48
    56
    64
    72
    80



  33. Get Number From User And Show Them Number Perfect Or Not




  34. Example
    #include<stdio.h>
    #include<conio.h>
    	int main()
    {
    	int no,sum,i;
    	printf("Enter the number : ");
    	scanf("%d",&no);
    	i=1;
    	sum=0;
    	while(i<no)
    	{
    		if (no%i==0)
    		{
    			sum=sum+i;
    		}
    		i++;
    	}
    	if(sum==no)
    	{
    		printf("number is perfect");
    	}
    	else
    	{
    		printf("number is not perfect");
    	}
    	getch();
    }
    

    Output
    Enter the number : 28
    number is perfect



  35. Make Any C Program Useing Do While




  36. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int n,b; printf("inter the num for limit : "); scanf("%d",&b); n=1; do { printf("\nHiiiii"); n++; } while(n<=b); getch(); }

    Output
    inter the num for limit : 6

    Hiiiii
    Hiiiii
    Hiiiii
    Hiiiii
    Hiiiii
    Hiiiii



  37. Get Number From User And Make Number Pattern




  38. Example
    #include<stdio.h>
    #include<conio.h>
    	void main()
    {
    	int n,i,j,sum=0;
    	printf("\n Enter the number : ");
    	scanf("%d",&n);
    	for(i=n;i>0;i--)
    	{
    		for(j=0;j<i;j++)
    		{
    			sum++;
    			printf("%d \t",sum);
    		}
    		printf("\n");
    	}
    	getch();
    }

    Output
    Enter the number : 8
    1 2 3 4 5 6 7 8
    9 10 11 12 13 14 15
    16 17 18 19 20 21
    22 23 24 25 26
    27 28 29 30
    31 32 33
    34 35
    36



  39. Get Number From User And Make Charector Pattern




  40. Example
    #include<stdio.h>
    #include<conio.h>
    	void main()
    {
    	int i,j,n;
    	char ch1,ch2;
    	printf("\n Enter no of line : ");
    	scanf("%d",&n);
    	for(i=0;i<n;i++)
    	{
    		ch1='A',ch2='a';
    		for(j=0;j<=i;j++)
    		{
    			printf("%c%c \t",ch1,ch2);
    			ch1++;
    			ch2++;
    		}
    		printf("\n");
    	}
    	getch();
    }
    

    Output

    Enter no of line : 8
    Aa
    Aa Bb
    Aa Bb Cc
    Aa Bb Cc Dd
    Aa Bb Cc Dd Ee
    Aa Bb Cc Dd Ee Ff
    Aa Bb Cc Dd Ee Ff Gg
    Aa Bb Cc Dd Ee Ff Gg Hh



  41. Get 10 Numbers From User And Store In Array Or Display Them




  42. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a[10],i; for(i=1;i<=10;i++) { printf("Enter the number : "); scanf("%d",&a[i]); printf("\n"); } for(i=1;i<=10;i++) { printf("The values are = %d \n",a[i]); } getch(); }

    Output
    Enter the number : 4

    Enter the number : 5

    Enter the number : 6

    Enter the number : 7

    Enter the number : 2

    Enter the number : 3

    Enter the number : 1

    Enter the number : 9

    Enter the number : 2

    Enter the number : 7

    The values are = 4
    The values are = 5
    The values are = 6
    The values are = 7
    The values are = 2
    The values are = 3
    The values are = 1
    The values are = 9
    The values are = 2
    The values are = 7



  43. Get 10 Numbers From User And Store In Array And Display How Many Odd Numbers




  44. Example
    #include<stdio.h>
    #include<conio.h>
    	void main()
    {
    	int a[10],i,cnt=0;
    	printf("Enter the number : \n");
    	for(i=0;i<10;i++)
    	{
    		scanf("%d",&a[i]);
    	}
    	for(i=0;i<10;i++)
    	{
    		if(a[i]%2!=0)
    		{
    			printf("%d",a[i]);
    			cnt++;
    		}
    	}
    	printf("total odd numbers are = %d",cnt);
    	getch();
    }
    

    Output
    Enter the number :
    4
    2
    6
    8
    12
    14
    16
    18
    3
    9
    39total odd numbers are = 2



  45. Bonus Program




  46. Example
    #include<stdio.h>
    #include<conio.h>
    
    void main() { int a=1,b,c; float d; printf("Enter the 1st number:"); scanf("%d",&b); printf("Enter the 2nd number:"); scanf("%d",&c); printf("\n Please type a number of following condition , thank you"); printf("\n \n 1:+\n 2:-\n 3:*\n 4:/\n"); scanf("%d",&a); switch(a) { case 1: d=b+c; printf("\n you choice addition which is=%f",d); break; case 2: d=b-c; printf("\n you choice subtraction which is=%f",d); break; case 3: d=b*c; printf("\n you choice multiplication which is=%f",d); break; case 4: d=b/c; printf("\n you choice division which is=%f",d); break; default: printf("\n you not choice proper condition"); } getch(); }

    Output
    Enter the 1st number:8
    Enter the 2nd number:15

    Please type a number of following condition , thank you

    1:+
    2:-
    3:*
    4:/
    3


    you choice multiplication which is=120.000000