3. Write a shell script to generate marksheet of a student. Take 3 subjects, calculate and display total marks, percentage and Class obtained by the student. Make a file called marksheet.sh using vim. If you want a full guide to vim than you can check this post. tkanu025@hp:~/lab_solutions$ vim marksheet.sh When you will hit enter than it will open a window like the one below. This is an editor and Here you can write your code. Press i to enter into the insert mode Write full code there like this echo "Enter marks(out of 30) of " read -p "Subject 1: " s1 read -p "Subject 2: " s2 read -p "Subject 3: " s3 sum=`expr $s1 + $s2 + $s3` echo "Sum of marks of 3 subjects is : "$sum per=`expr $sum \* 10 / 9` echo "Percentage: "$per if [ $per -ge 60 ] then echo "you got Distinction" elif [ $per -ge 50 ] then echo "you got First class" elif [ $per -ge 40 ] then ...
19. Write a program to generate first n number of Fibonacci series. #include<stdio.h> #include<conio.h> int main() { int n,a,b,c,i; a=0; b=1; printf("\nEnter value of n : "); scanf("%d",&n); printf("\nFibonacci series is\n"); printf("\n%d\t%d",a,b); for(i=1;i<=n-2;i++) { c=a+b; a=b; b=c; printf("\t%d",b); } getch(); return 0; } Sample output Previous Program Next Program
3. Write a program to calculate simple interest(i= p*r*n/100). where, i - simple interest p - principal amount r - Rate of interest n - Number of years #include<stdio.h> #include<conio.h> int main() { int p,n; float rate,si_int; printf("\n\nEnter principal amount : "); scanf("%d",&p); printf("\nEnter number of years : "); scanf("%d",&n); printf("\nenter rate of interest : "); scanf("%f",&rate); si_int = p*rate*n/100; printf("\nSimple interest is %f",si_int); getch(); return 0; } sample output Previous Program Next Program
Comments