You are on page 1of 3

NAME: SONU KUMAR KESHRI

ROLL:1904026
ASSIGNMENT 2 CSL3501

CODE 1
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

int main()

int i;

char Name[20];

printf("Enter Your string to be reversed:\n");

scanf("%s",&Name);

printf("The reverse of the string is %s :",strrev(Name));

return 0;

OUTPUT:

Enter Your string to be reversed:

SONU1234KUMAR

The reverse of the string is RAMUK4321UNOS :

Process returned 0 (0x0) execution time : 14.326 s

Press any key to continue.


CODE 2

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

int main()

int n,i;

char Name[20];

printf("Enter Your string:\n");

scanf("%s",&Name);

printf("Enter the position of character you want to print starting from 1 ;\n");

// here i have assumed counting of letters from 1 and not zero. Real life thing

scanf("%d",&n);

if(n<(strlen(Name))+1){

printf("The Character you desire is %c\n ",Name[n-1]);

else{

printf("Out of limit, enter n again !!!");

return 0;

OUTPUT:
Enter Your string:

13reasonsWhy

Enter the position of character you want to print starting from 1 ;

The Character you desire is o

Process returned 0 (0x0) execution time : 27.541 s

Press any key to continue.

You might also like