CSS Forums

CSS Forums (http://www.cssforum.com.pk/)
-   Computer Science (http://www.cssforum.com.pk/css-optional-subjects/group-i/computer-science/)
-   -   Answers required for computer science paper (http://www.cssforum.com.pk/css-optional-subjects/group-i/computer-science/129930-answers-required-computer-science-paper.html)

davidweb Sunday, February 20, 2022 07:31 PM

Answers required for computer science paper
 
Complete the code such that it prompts the user for +ve number n. Then displays the output.(whatever the value of n is)(HINT: instead of triangles of stars its triangles of increasing numbers)

1 2 3 4 . . . n
1 2 3 4 ..n-1
. . .
. . .
1 2
1

for n=4 it will print
1 2 3 4
1 2 3
1 2
1
void main()
{
int n; cin>>n;

// your loops will go here

}



In following code replace the character at posth location in the string st with the ,character ch. For example in string helloworld replacing 2nd character with i would result in hilloworld

void main( )

{char st[15]; int pos; char ch;
int size=0;
cin>>st;
cin>>pos>>ch;
while(st[size]!='\0')
{
size++; // calculating length of current string
}
// write your code here


12:58 AM (GMT +5)

vBulletin, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.