The algorithm for a Java code to take a string from the user and printing its Piglatin as as follows: Step1 START Step2 Store string in s Step3 Store length in n Step4 int i,c=0; Step5 int i=0; Step6 if i<n,goto step7,else goto step10 Step7 character at i in ch Step8 if “aeiouAEIOU”.indexOf(ch)!=-1,goto step10 Step9 i++;goto step6 Step10 if i==n,s=s+’N’; Step11 if i==0,s=s+’Y’; Step12 …
Write A Program In Java To Enter A String And Print Frequency Of Each Character
The algorithm for a Java code to take a string and print frequency of each character is as follows: Step1 Store string in a Step2 int d=0;a=a.toLowerCase();int l=a.length() Step3 int i=97; Step4 if i<=122,goto step5,else goto step12 Step5 int j=0; Step6 if j<l,goto step7,else goto step9 Step7 if characeter of i=character at j,d++; Step8 j++;goto step6 Step9 if d>0,print frequency of i=d Step10 d=0; Step11 i++;goto step4 Step12 END The java program code to take …
Write A Program In Java To Enter A String And Print The First Letter Of Every Word In Capital Letters
The algorithm for a Java code to take a string from the user and to print the first letter of every word of it in capital letters would be as follows: Step1 START Step2 Store the string in a Step3 a=a.toLowerCase(); Step4 Print the first character of text in capital Step5 int i=1; Step6 if i<a.length(),goto step7,else goto step11 Step7 if character at (i-1)!=’ ‘,goto step8,else goto step9 Step8 print character at i Step9 print …
Write A Program In Java To Enter A String And Print It In Alphabetical Order
The algorithm for creating a program to enter a string and printing it in alphabetical order is as follows: Step1 START Step2 Store string in a Step3 Calculate no. of characters and store in l Step4 i=97 Step5 if i<122,goto step6 else goto step13 Step6 Convert string in lower case Step7 j=0 Step8 if j<l,goto step9 else goto step12 Step9 Store ASCII ofcharacter at position j Step10 if ASCII = j,print the character Step11 j++,goto …
Program In C To Find The Factorial Of A Number Using Recursion
The C code for a program to find the factorial of a number using recursion would be as following: The Code is as following: #include<stdio.h> #include<conio.h> int fact(int x) { int y; if(x==0) return 1; else { y=x-1; x=x*fact(y); } return x; } void main() { clrscr(); int n; printf("enter a number to find its factorial \n"); scanf("%d",&n); printf("\n factorial of %d is: %d",n,fact(n)); getch(); }
Program In C To Find The Largest Of Three Numbers Using Nesting Of Functions
The C code for a program to find the largest of three numbers using nesting of functions would be as following: The Code is as following: #include<conio.h> #inlcude<stdio.h> int big(int a,int b) { if(a>b) return a; else return b; } void main() { clrscr(); int x,y,z; printf("enter 3 numbers to find largest of Three \n"); scanf("%d %d %d",&x,&y,&z); printf("largest of three is: %d",big(x,big(y,z))); getch(); }
Program In C To Find The Size Of A Structure
The C code for a program to find of a structure in C programming language would be as following: The Code is as follows #include<conio.h> #include<stdio.h> struct student { int Rno; char Name[5]; }s; void main() { clrscr(); int size; size=sizeof(s); printf("size of structure student is: %d bytes",size); getch(); }
C Program To Print The Address Of A Variable Using ‘*’ And ‘&’ Operator
The C code for a program to print the address of a variable using * or & operator would be as following: The code is as following: #include<stdio.h> #include<conio.h> void main() { clrscr(); int a=10,*ptr; ptr=&a; printf("value of the variable a=%d",*ptr); printf("\naddress of the variable a=%p",ptr); getch(); }
Program In C to Display The Use Of Pointers As Arithmetic Operations
The code for a program to display the use of pointers as arithmetic operations would be as followingL The Code is as following: #include<stdio.h> #include<conio.h> void main() { clrscr(); int sum,a,b,*ptr1,*ptr2; ptr1=&a; ptr2=&b; printf("enter 2 numbers to add \n"); scanf("%d %d",&a,&b); sum= (*ptr1) + (*ptr2); printf("SUM = %d",sum); getch(); }
Program In C To Copy One Structure To Another And Compare Them
The code for a program to copy a structure to another and compare them would be as following: The Code is as following: #include<stdio.h> #include<conio.h> #include<string.h> struct student { char name[10]; int rno; }; void main() { clrscr(); student s1={"Rohit",52}; student s2; s2=s1; // structure copying if(strcmp(s1.name,s2.name)==0) // structure comparison if(s1.rno==s2.rno) printf("equal structures"); else printf("unequal structures"); getch(); }
