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 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 ...
20). Write a GUI program that use button to move the message to the left and right and use the radio button to change the color for the message displayed. import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.BorderPane; import javafx.scene.text.Text; import javafx.scene.control.RadioButton; import javafx.scene.control.ToggleGroup; import javafx.scene.paint.Color; public class Program_20 extends Application { protected Text text = new Text(50, 50, "Learning JavaFX is exciting"); @Override // Override the stage method in the Application class public void start(Stage primaryStage) { HBox paneForButtons = new HBox(20); Button btLeft = new Button("<="); Button btRight = new Button("=>")...
Comments