#include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter two numbers"); scanf("%d,%d",&a,&b); if(a>b) { printf("%d is greater",a); } else { printf("%d is greater",b); } getch(); }
... int i; for( i = 0; i < 7; ++i ) { printf("*"); } printf("\n"); ...
#include<stdio.h> main(void) { int n; int i; printf("Type n: "); scanf("%d",&n); for(i=1;i<=n;i++) //generates natural numbers from 1,....,n. printf("%d\n",i); //prints these numbers to standard output }
#include<stdio.h> main() { int a,i=1; printf("Enter max no"); scanf("%d",&a); do { printf("%d",i); i=i+2; }while(i<=a); }
#include "stdio.h" int main() { unsigned int number, count; printf("Enter the Number \t"); scanf("%d", &number); printf("The even numbers are: \n"); for(count = 0x01; (count < number && number!= 0x00)) { if(count%2) { }else { printf("%d\n", count); } count++; } return 0; }
for(i=1;i<=5;i++) { for(x=5;x>=i;x--) { printf(" "); } for(j=1;j<=2*i-1;j++) { printf("1"); } printf("\n"); }
#include<stdio.h> #include<conio.h> void main() { int i, a[100]; clrscr(); printf("Numbers from 1 to 100"); for(i=1;i<=100;i++) printf(" %d",a[i]); printf("Numbers from 1 to 100 without multiples of 2"); for(i=1;i<=100;i++) { if (a[i]%2 !=0) printf(" %d",a[i]); } printf("Numbers from 1 to 100 without multiples of 3"); for(i=1;i<=100;i++) { if (a[i]%3 !=0) printf(" %d",a[i]); } printf("Numbers from 1 to 100 without multiples of 4"); for(i=1;i<=100;i++) { if (a[i]%4 !=0) printf(" %d",a[i]); } printf("Numbers from 1 to 100 without multiples of 5"); for(i=1;i<=100;i++) { if (a[i]%5 !=0) printf(" %d",a[i]); } printf("Numbers from 1 to 100 without multiples of 6"); for(i=1;i<=100;i++) { if (a[i]%6 !=0) printf(" %d",a[i]); } printf("Numbers from 1 to 100 without multiples of 7"); for(i=1;i<=100;i++) { if (a[i]%7 !=0) printf(" %d",a[i]); } printf("Numbers from 1 to 100 without multiples of 8"); for(i=1;i<=100;i++) { if (a[i]%8 !=0) printf(" %d",a[i]); } printf("Numbers from 1 to 100 without multiples of 9"); for(i=1;i<=100;i++) { if (a[i]%9 !=0) printf(" %d",a[i]); } getch(); }
#include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter two numbers"); scanf("%d,%d",&a,&b); if(a>b) { printf("%d is greater",a); } else { printf("%d is greater",b); } getch(); }
void print_num_as_word (unsigned num) { switch (num) { case 0: printf ("zero"); break; case 1: printf ("one"); break; case 2: printf ("two"); break; case 3: printf ("three"); break; case 4: printf ("four"); break; case 5: printf ("five"); break; case 6: printf ("six"); break; case 7: printf ("seven"); break; case 8: printf ("eight"); break; case 9: printf ("nine"); break; } }
#include<stdio.h> #include<conio.h> void main() { int a,b,c; int menu; printf("choose the arithmetic option\n"); scanf("%d",&menu); switch(menu) { case 1: printf("Enter The Two Numbers:\n"); scanf("%d%d",&a,&b); c=a+b; printf("The addition of two numbers %d\n",c); break; case 2: printf("Enter THE TWO NUMBERS:\n"); scanf("%d%d",&a,&b); c=a-b; printf("The subtraction of two numbers %d\n",c); break; case 3: printf("Enter THE TWO NUMBERS:\n"); scanf("%d%d",&a,&b); c=a*b; printf("The multiplication of two numbers %d\n",c); break; case 4: printf("Enter THE TWO NUMBERS:\n"); scanf("%d%d",&a,&b); c=a/b; printf("The division of two numbers %d\n",c); break; } getch(); }
a=10; b=20; c=`expr $a + $b`; printf "$c";
#include<stdio.h> int main (void) { int a, b; printf("Enter two numbers: "); scanf ("%d %d", a, b); printf ("The sum of %d and %d is %d\n", a, b, a+b); return 0; }
You can use fputs() instead of printf().
Answer: #include<stdio.h> #include<conio.h> main() { int a,b,i=1,c1,c2,m; clrscr(); printf("\nENTER THE VALUE OF a,b:"); scanf("d",&a,&b); c1=a+i*b; c2=a-i*b; printf("\n"); pritnf("\nTHE COMPLEX NUMBERS ARE:"); printf("\n); printf("a+ib=%d\ta-ib=%d",c1,c2); m=c1*c2; m=(a*a)+(b*b); printf("\n"); printf("\nTHE MUL OF TWO COMPLEX NUMBERS IS=%d",m); getch(); } Answer: z.real = x.real*y.real - x.imag*y.imag; z.imag = x.real*y.imag + x.imag*y.real;
we write printf() b/c it printf or show us the value contained in a value on the screen after pressing ctrl+f9.
#include <stdio.h> int main (void) { int i,j; for (i=1;i<5;i++) { for(j=1;j<=i;j++) printf("%d",j); printf("\n"); } return 0; }
... int i; for( i = 0; i < 7; ++i ) { printf("*"); } printf("\n"); ...