Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

QUESTION 1 #include<stdio.

h> int main(){ int k,r; long int i=0l,j=1,f; //Taking maximum numbers form user printf("Enter the number range:"); scanf("%d",&r); printf("FIBONACCI SERIES: "); printf("%ld %ld",i,j); //printing firts two values. for(k=2;k<r;k++){ f=i+j; i=j; j=f; printf(" %ld",j); } return 0; } QUESTION 2(i) #include <stdio.h> #include <stdlib.h> main() { int i;//variable decralation int j;//variable decralation for (i=1; i<=5; i++)//for loop to control the columns { for (j=1; j<=i; j++)//for loop to control lows { printf("*" );//the output statement } printf("\n");//printing new line } return 0; } QUESTION 2(ii) #include <stdio.h> #include <stdlib.h> main() { int i;//variable decralation int j;//variable decralation int k; for (i=1; i<=5; i++)//for loop to control the columns { for (j=1; j<=i; j++)//for loop to control lows

{ printf("*" );//the output statement } printf("\n");//printing new line } for (i=5-2; i>=0; i--)//for loop to control the columns { for (j=i; j>=0; j--)//for loop to control lows { printf("*" );//the output statement } printf("\n");//printing new line } return 0; }

#include <stdio.h> #include <stdlib.h> int main() { int n; int sum=0; int i; int s[n]; printf("please enter number of digits you want"); scanf("%d",&n); printf("now enter %d interges you want",n); scanf("%d",&s[n]); for (i=0;i<=n;i++) sum=sum+s[i]; printf("%d",sum); return 0; }

#include <stdio.h> #include <stdlib.h> int main() {

int int int int

n; sum=0; i; k;

printf("please enter number of digits you want"); scanf("%d",&n); int s[n]; printf("now enter %d integers you want\n",n); for(i = 0; i < n; i++){ scanf("%d", &s[i]); } printf("enter the weight %d number you have entered \n",n); for(k = 0; k < n; k++){ scanf("%d", &s[k]); } printf("Choose from the following"); printf("a. Calculate the sum of the entered number\n b. calculate the avarage o f the entered number \n c. Calculate the weighted avarage of the entered number" ); return 0; }

You might also like