'n' can be an identifier, '1' is a digit
#include<stdio.h> main() { int i; for(i=1;i<=1;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=5;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=1;i++) { printf("*",i); } }
#include<stdio.h> #include<conio.h> void main() { int a=-1,b=1,c=0,i,n; clrscr() printf("Enter the limit"); scanf(%d,&n) printf(the resultant fibonacci sequence is:) for(i=1;i<=n;i++) { c=a+b; printf(%d, c) a=b; b=c; } getch(); }
for (int n = 0; n <=100; n++) // you may start n = 1, same result, 1 less iteration { if (n % 6) // or, n % 6 != 0 printf(n); }
#include<iostream.h> #include<conio.h> void main() { clrscr(); int i,k,a[10],c[10],n,l; cout<<"Enter the no. of elements\t"; cin>>n; cout<<"\nEnter the sorted elments for optimal merge pattern"; for(i=0;i<n;i++) { cout<<"\t"; cin>>a[i]; } i=0;k=0; c[k]=a[i]+a[i+1]; i=2; while(i<n) { k++; if((c[k-1]+a[i])<=(a[i]+a[i+1])) { c[k]=c[k-1]+a[i]; } else { c[k]=a[i]+a[i+1]; i=i+2; while(i<n) { k++; if((c[k-1]+a[i])<=(c[k-2]+a[i])) { c[k]=c[k-1]+a[i]; } else { c[k]=c[k-2]+a[i]; }i++; } }i++; } k++; c[k]=c[k-1]+c[k-2]; cout<<"\n\nThe optimal sum are as follows......\n\n"; for(k=0;k<n-1;k++) { cout<<c[k]<<"\t"; } l=0; for(k=0;k<n-1;k++) { l=l+c[k]; } cout<<"\n\n The external path length is ......"<<l; getch(); }
The only difference between dynamic programming and back tracking is DP allows overlapping of sub problems. (fib(n) = fib(n-1)+ fib (n-2)).
to find the factorial we declare a variable n and initialize its value to 1 initiate a loop for example a for loop and multiply the numbers upto 5 code:- for(i=1,n=1;i<=5;i++) { n=n*i; }
Infinite execution is obtained by, #include main( ) { int i; for(i=1;i>0;i++) { printf(''/n%d'',i); } }
#include<stdio.h> main() { int i; for(i=1;i<=1;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=5;i++) { printf("*",i); } printf("\n"); for(i=1;i<=3;i++) { printf("*",i); } printf("\n"); for(i=1;i<=1;i++) { printf("*",i); } }
what is the meaning of n d i c.
#include<stdio.h> #include<conio.h> void main() { int a=-1,b=1,c=0,i,n; clrscr() printf("Enter the limit"); scanf(%d,&n) printf(the resultant fibonacci sequence is:) for(i=1;i<=n;i++) { c=a+b; printf(%d, c) a=b; b=c; } getch(); }
hi my name is stinky carina n i smell like my best daddy, n i like it , n me n my dad is twins
non conforming
Here is the code to do it: #include<stdio.h> main() { int n, c, k, space = 1; //Here we ask for the number of rows would be : printf("Enter number of rows\n"); scanf("%d",&n); space = n - 1; //This is the first half of the diamond for ( k = 1 ; k <= n ; k++ ) { for ( c = 1 ; c <= space ; c++ ) printf(" "); space--; for ( c = 1 ; c <= 2*k-1 ; c++) printf("*"); printf("\n"); } space = 1; //Here is the second half of the diamond for ( k = 1 ; k <= n - 1 ; k++ ) { for ( c = 1 ; c <= space; c++) printf(" "); space++; for ( c = 1 ; c <= 2*(n-k)-1 ; c++ ) printf("*"); printf("\n"); } return 0; } Hope that helped :)
for (int n = 0; n <=100; n++) // you may start n = 1, same result, 1 less iteration { if (n % 6) // or, n % 6 != 0 printf(n); }
what is the full meaning of N.N.P.C.?
The following code for example is a solution (you could do it with less variables, but this is more readable):int GCD(int a, int b){int n, k, c;n = (a>b)?a:b;k = (a>b)?b:a;while (k){c = n%k;n=k;k=c;}return n;}
#include#includevoid main(){int a[10],i=0,c=0,n;printf("\n enter the gray code");scanf("%d",&n);while(n!=0){a[i]=n%10;n/=10;i++;c++;}for(i=c-1;i>=0;i--){if(a[i]==1){if(a[i-1]==1)a[i-1]=0;elsea[i-1]=1;}}printf("\n the binary code is");for(i=c-1;i>=0;i--)printf("%d",a[i]);getch();}