Question

After a group of numbers for example 1, 2, 3, 4, 5. how would I go...

After a group of numbers for example 1, 2, 3, 4, 5. how would I go about getting the last number to printf with a period? Also the length of the numbers will change. For example there might be a 6 after the five or a 7 after the 5 and 6. Without using backslashes

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
int main(){
   int n;
   printf("How many numbers to print? ");
   scanf("%d", &n);
   for(int i = 1; i <= n; i++){
       if(i != 1)
           printf(", ");
       printf("%d", i);
   }
   printf(".");
   printf("\n");
}

Add a comment
Know the answer?
Add Answer to:
After a group of numbers for example 1, 2, 3, 4, 5. how would I go...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • this is in regards to example 2, i know i need to isolate 'n' but how...

    this is in regards to example 2, i know i need to isolate 'n' but how exactly would i go about that? • random error of ave =(error in one measurement)/n12 n is # of measurements Example 1: The mass shown on the balance after several additions of a powder tends to have a lower random error than any single mass addition. After clicking dispense five times consecutively, if each single addition has a random error of 10 %, what...

  • Let's say you are given a sequence of distinct positive numbers. We want to find a...

    Let's say you are given a sequence of distinct positive numbers. We want to find a subsequence with the maximum possible sum, with the restriction that we are not allowed to take three consecutive elements from the original sequence. For example, for input 1, 6, 5, 2, 7, 9, 3, 4, the subsequence with the maximum possible sum is 6, 5, 7, 9, 4 (we have two pairs of consecutive elements 6, 5 and 7, 9 but not three consecutive...

  • Could you please provide a detailed step by step explanation as to how I should go...

    Could you please provide a detailed step by step explanation as to how I should go about obtaining the output shown for each program fragment. Thanks. a) int f1 (int x) { int y=3; printf("%d%d",x,y); return x++; } int main (void) { int y=6, x=4; printf("%d\n",f1(y)); printf("%d%d\n",x,y); return 0; } OUTPUT: x=6, y=36 x=4, y=6 b) void f2(int n, int a[]) { for (int i=0;i<n;i++) a[i] += a[i+1]; } int main() { int A[]={1,2,3,3,4,5};int i, N=6; for (i=0;i<N;i++) printf("%d ",A[i]);...

  • Can someone do 2,6,8,12 34 Exercises 187 EXAMPLE 7 GETTING FIVE HEARTS Find the probability of being dealt five bearts...

    Can someone do 2,6,8,12 34 Exercises 187 EXAMPLE 7 GETTING FIVE HEARTS Find the probability of being dealt five bearts SOLUTION The sample is the same as in Example 5. The event consists of all pos- hands that include five hearts and no non-hearts This involves cltegories (hearts and non-hearts), so we will use the Fundamental Count- hinciple and multiply the number of ways of getting five hearts and the sible number of ways of getting no non-hearts There are...

  • In a series of numbers, a "mini peak" is a set of 3 numbers where the...

    In a series of numbers, a "mini peak" is a set of 3 numbers where the middle number is strictly greater than its adjacent left and right neighbors. For example, the array: [ 4, 6, 2, 1 ] contains 1 mini peak, with 6 in the middle ([ 4, 6, 2]). Write full and complete C++ program to open a text file named numbers.txt in the working folder, which contains groups of numbers, one per line, with each group starting...

  • In Java how would I go about replacing the bits in the exponent field of a...

    In Java how would I go about replacing the bits in the exponent field of a float number with the ASCII '$'. (using AND and OR masks). all 8 bits of the exponent field

  • How many 3-digit numbers can be formed using the digits 1, 2, 3, 4, 5, 6,...

    How many 3-digit numbers can be formed using the digits 1, 2, 3, 4, 5, 6, 7, 8, and 9? Repeated digits are allowed.

  • 1. Given a set of numbers: A = {1, 3, 5, 2, 8, 7, 9, 4...

    1. Given a set of numbers: A = {1, 3, 5, 2, 8, 7, 9, 4 }. Add each digit of your N-Number (e.g. N0 0 3 2 2 0 1 8) to each element of A separately to get your own final array B. ( e.g. B={1,3,8,4,10,7,10,12} = {B1,B2,B3,B4,B5,B6,B7,B8}. ) a) Your set B = ? b) Use merge-sort to sort the array B. Show each step. c) How many “comparisons” for each algorithm above? 2. Use binary-search for...

  • How would I go about solving parts 2,3, and 4 in this problem? How would I...

    How would I go about solving parts 2,3, and 4 in this problem? How would I draw the product? I. (24 pts.) Indicate the type of reaction that will predominate (i.e., SN1, SN2, El, or E4), draw the structure of the major product when: 1. isopropyl chloride reacts with hydroxide predominate rxn. structure: 3. 2-iodopentane reacts with ethoxide in DMSO predominate rxn. structure: 2. t-butyl tosylate reacts with CH3OH predominate rxn. structure: 4. ethyl bromide reacts with CH30- predominate rxn....

  • 7-10 There is a new lottery game where twelve numbers are chosen from the set of numbers from 1 to 24, with no repeats. One of the ways to win is to match ZERO numbers, the other way to win is to...

    7-10 There is a new lottery game where twelve numbers are chosen from the set of numbers from 1 to 24, with no repeats. One of the ways to win is to match ZERO numbers, the other way to win is to match ALL the numbers. Order does not matter. 7. Calculate the probability of getting all the numbers correct. Show the setup of the numbers, in case calculations go silly and also to show that you didn't just Google...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT