0% found this document useful (0 votes)
9 views

Laborator

This program counts the number of commas in a user-input string. It takes the string as input, uses a for loop to iterate through each character, and uses the strchr() function to check if the character is a comma. If it is a comma, it increments the counter variable and removes the comma from the string. After the loop, it prints out the number of commas found and the new string without commas.

Uploaded by

Ion Sirbu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Laborator

This program counts the number of commas in a user-input string. It takes the string as input, uses a for loop to iterate through each character, and uses the strchr() function to check if the character is a comma. If it is a comma, it increments the counter variable and removes the comma from the string. After the loop, it prints out the number of commas found and the new string without commas.

Uploaded by

Ion Sirbu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Programul

#include<iostream.h> #include<string.h> #include<stdio.h>

Schema bloc

Start

#include<conio.h> main() { clrscr(); int i,k=0; char a[100],v[]=","; printf("Dati sirul\n"); scanf("%s,&a"); for(i=0;i<strlen(a);i++)
K++
(v,a[i])!=0

I=0,1,2..

Nu

Da

if(strchr(v,a[i])!=0) { k++; strcpy(a+i,a+i+1); } printf("Virgula a fost intilnita de=%d\n",k); printf("Sirul nou=%s",a); return 0; }
Stop K=,a=

You might also like